#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int majorityElement(int* nums, int numsSize)
{
    int ret = 0;
    int arr1[50001] = { 0 };
    int arr2[50001] = { 0 };
    int count = 0;
    int i = 0;
    int j = 0;
    for (i = 0; i < numsSize; i++)
    {
        int flag = 1;
        for (j = 0; j <= count; j++)
        {
            if (nums[i] == arr1[j])
            {
                flag = 0;
                break;
            }
        }
        if (flag)
        {
            arr1[count] = nums[i];
            count++;
            arr2[j-1]++;
        }
        else
        {
            arr2[j]++;
        }
    }
    for (i = 0; i < count; i++)
    {
        if (arr2[i] > (numsSize / 2))
        {
            ret = arr1[i];
        }
    }
    return ret;
}

int main() 
{
    int arr[3] = { 3,2,3 };
    printf("%d",majorityElement(arr, 3) );
    return 0;
}